'use strict';
angular.module('clientApp')
.value('userURL', 'http://127.0.0.1:8080/M2TIIL_AERO_2015')
.factory('userAPI', function($http, userURL) {
    return {
        add : function(user) {
            return $http({
                url : userURL + '/addUser.htm?name=' + user.name + '&password=' + user.password + '&mail=' + user.mail,
                method : 'POST',
                headers : {
                    'Content-Type' : 'application/json'
                }
            });
        },
        get : function(id) {
            return $http({
                url : userURL + '/getUser.htm?idxUser=' + id,
                method : 'GET',
                headers : {
                    'Content-Type' : 'application/json'
                }
            });
        },
        connexion : function(user) {
        	return $http({
                url : userURL + '/connexionUser.htm?log=' + user.name + '&password=' + user.password,
                method : 'GET',
                headers : {
                    'Content-Type' : 'application/json'
                }
            });
        }
    };
});
